package com.sj;

import org.junit.Test;

public class NumberUtil {
    /**
     * 字符串转数字，下一个数字，保持位数不变
     *
     * @return
     */
    public static String nextStr(String value) {
        int v = Integer.parseInt(value);
        StringBuilder result = new StringBuilder();
        result.append(++v);
        int length = value.length() - result.length();
        while (length > 0) {
            result.insert(0, "0");
            length--;
        }
        return result.toString();
    }

    @Test
    public void t() {
        String result = NumberUtil.nextStr("999998");
        System.out.println(result);
        result = NumberUtil.nextStr(result);
        System.out.println(result);
        result = NumberUtil.nextStr(result);
        System.out.println(result);
    }
}
